<?php 

$GLOBALS["conn"]->BeginTrans();
$Sql ="SELECT
information_schema.`TABLES`.TABLE_NAME as tablename
FROM
information_schema.`TABLES`
where
information_schema.`TABLES`.TABLE_SCHEMA = DATABASE()  ";

$rs=$GLOBALS["conn"]->Execute($Sql);



while (!$rs->EOF)  {
	
	$tablename=$rs->fields["tablename"];
	//echo $tablename."<br/>";
	
	$sql="INSERT IGNORE INTO portal_objects (`name`,`lib_FR`,`lib_AR`,`lib_EN`) VALUES ('$tablename','$tablename','$tablename','$tablename') ";
//	echo $sql."<br/>";
	$GLOBALS["conn"]->Execute($sql);
	
	$rs->MoveNext();
}


$GLOBALS["conn"]->CommitTrans();

$url=addParameter("editrights","ok");

if (getParameter("editrights")=="ok")
{
	

	$GLOBALS["conn"]->BeginTrans();
	$objectName=getObjByKey("portal_objects","id","name","portal_objects");
	$groupId=getParameter("group");
	$SQL="SELECT * FROM portal_objects";
	$rs=ew_LoadRecordset($SQL);
	while (!$rs->EOF) {
		
	
	$objectId=$rs->fields["id"];
	$SQL="INSERT IGNORE INTO portal_credentials VALUES (NULL,$objectId,$objectName,'".getParameter("right")."',$groupId,$portalId)";
	//echo $SQL."<br/>";
	ew_LoadRecordset($SQL);
	$rs->MoveNext();
	
	}
	ShowSuccess("Success");
	$GLOBALS["conn"]->CommitTrans();
	}
	
	
?>


<div class="cadretop">Edit Rights</div>
<div class="cadre">
<form action="<?=$url?>" method="POST">
<input type="image" width="32" border="0" title="Copy" src="./images/menu/portal_credentials.png">
<input type="hidden" name="editrights" value="ok">

    <?php targetGroups(); ?>
</form>

    
</div>